<template>
    <div class="main">
        <!--动态组件-->
        <component :is="currentComponent"></component>
        <tool-bar @onChangeFragment="onChangeFragment"></tool-bar>

    </div>
</template>

<script>
    import toolBar from '@c/ToolBar.vue'

    export default {
        components: {
            'tool-bar': toolBar,
            'home': () => import('@c/Home'),
            'shopping': () => import('@c/Shopping'),
            'my': () => import('@c/My')
        },
        data() {
            return {
                currentComponent:'home'
            }
        },
        methods: {
            //实现组件的切换
            onChangeFragment(componentName) {
                console.log(componentName);
                this.currentComponent=componentName;
            }
        }
    }
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
    .main {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

</style>